package com.xzm.project.ui.adapter;

import android.content.Intent;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xzm.project.R;
import com.xzm.project.ui.bean.DemoItem;

import java.util.List;

/**
 * Created by xuzongmeng on 2017/1/13.
 */

public class DemoItemAdapter extends BaseQuickAdapter<DemoItem,BaseViewHolder> {
    public DemoItemAdapter() {
        super(R.layout.item_demo);
    }
    @Override
    protected void convert(final BaseViewHolder holder, final DemoItem item) {
//        item.getClassName().getSimpleName().replace(item.getClassName().getSimpleName(),"Activity");
        String name = item.getClassName().getSimpleName();
        holder.setText(R.id.tv_class_name, name.substring(0,name.length()-8))
        .setText(R.id.tv_description,item.getDescription());
        holder.itemView.setOnClickListener(v -> {
            mContext.startActivity(new Intent(mContext, item.getClassName()));
//            ToastUtil.showToast("点击="+item.getClassName().getSimpleName());
        });
    }

    public String deleteCharString(String sourceString, char chElemData) {
        String deleteString = "";
        for (int i = 0; i < sourceString.length(); i++) {
            if (sourceString.charAt(i) != chElemData) {
                deleteString += sourceString.charAt(i);
            }
        }
        return deleteString;
    }

}
